# Contributor: rubicon <rubicon@mailo.com>
# Maintainer:
pkgname=ocaml-mirage-kv
_pkgname=mirage-kv
pkgver=4.0.1
pkgrel=2
pkgdesc="MirageOS signatures for key/value devices"
url="https://github.com/mirage/mirage-kv"
arch="all !riscv64"  # limited by ocaml aport
license="ISC"
depends="ocaml-runtime ocaml-fmt ocaml-lwt"
depends_dev="$pkgname=$pkgver-r$pkgrel ocaml-fmt-dev ocaml-lwt-dev"
makedepends="dune ocaml"
checkdepends="ocaml-alcotest-dev"
options="!check"
subpackages="$pkgname-dev"
source="$pkgname-$pkgver.tar.bz2::https://github.com/mirage/mirage-kv/releases/download/v$pkgver/mirage-kv-$pkgver.tbz"
builddir="$srcdir/$_pkgname-$pkgver"
_ocamldir=usr/lib/ocaml

# 32-bit archs
case "$CARCH" in
	arm*|x86) options="$options textrels" ;;
esac

build() {
	dune build --release --verbose
}

check() {
	dune runtest --verbose
}

package() {
	dune install \
		--destdir="$pkgdir" \
		--docdir=/.omit
	rm -Rf "$pkgdir"/.omit
}

dev() {
	default_dev

	cd "$pkgdir"

	local path; for path in $(find $_ocamldir \( \
			-name '*.cmt' -o \
			-name '*.cmti' -o \
			-name '*.cmx' -o \
			-name '*.cmxa' -o \
			-name '*.ml' -o \
			-name '*.mli' \
		\))
	do
		amove "$path"
	done
}

sha512sums="
e6ac8b8638eac760d245edb0159366c313ff9f5986fd310557fa6bec6f9fb87a3bb59d73065b42d2a798779d7b41cb81da235624db8e836f44801c4ae20c0293  ocaml-mirage-kv-4.0.1.tar.bz2
"
